'''
Created on Jan 29, 2013

@author: Hui
'''

a =[
[(5, 2, 3), (8, 1, 7), (8, 1, 12), (9, 1, 11), (9, 3, 5), (9, 3, 6), (10, 1, 8), (10, 3, 6), (11, 1, 11), (11, 1, 11), (11, 10, 10), (12, 1, 8), (13, 2, 9), (13, 10, 10), (14, 1, 11), (15, 3, 10), (17, 1, 16), (17, 4, 20), (17, 4, 21), (20, 3, 14)]
,
[(5, 1, 4), (5, 6, 6), (6, 4, 2), (8, 2, 8), (8, 3, 5), (8, 8, 8), (9, 8, 8), (10, 3, 6), (10, 4, 6), (11, 1, 7), (11, 1, 9), (11, 1, 9), (11, 3, 5), (11, 3, 8), (11, 3, 10), (11, 9, 9), (11, 10, 10), (12, 3, 8), (12, 3, 8), (12, 3, 14), (12, 4, 8), (13, 1, 8), (13, 1, 11), (13, 2, 9), (13, 2, 11), (13, 13, 13), (13, 13, 13), (14, 5, 16), (15, 2, 13), (15, 3, 9), (15, 4, 8), (15, 6, 12), (16, 3, 11), (17, 4, 20), (17, 4, 20), (17, 4, 20), (17, 4, 21), (18, 1, 14), (18, 4, 11), (20, 6, 14)]
,
[(7, 3, 2), (8, 1, 9), (8, 2, 4), (9, 2, 7), (9, 4, 4), (9, 8, 8), (9, 8, 8), (10, 2, 7), (10, 2, 7), (10, 2, 8), (10, 2, 9), (10, 2, 9), (10, 2, 11), (10, 4, 8), (10, 10, 10), (10, 11, 11), (11, 2, 7), (11, 2, 8), (11, 2, 9), (11, 3, 9), (11, 3, 12), (11, 8, 8), (11, 10, 10), (12, 1, 11), (12, 2, 8), (12, 3, 6), (12, 3, 7), (12, 3, 7), (12, 3, 8), (12, 3, 9), (13, 1, 11), (14, 2, 8), (14, 2, 10), (14, 3, 11), (15, 3, 6), (16, 3, 12), (16, 5, 15), (16, 7, 10), (16, 13, 13), (17, 4, 20), (17, 4, 20), (17, 4, 20), (17, 4, 20), (17, 4, 20), (17, 6, 14), (17, 13, 13), (18, 1, 14), (18, 1, 16), (18, 2, 13), (18, 2, 13)]

]

res = []

for a1 in a:
    res = res + a1
    
#print res
    
res = sorted([(change,before, after) for (before, after, change) in res if (before-after > 3) and (change < 20)])
    
#print res 

length = len(res)
unit = float(1)/length

curr = 0

flag = 0
for (changed,before,after) in res:
    curr += unit
    print('\draw [->] ({0},{1}) -- ({0},{2}); \draw[dotted] ({0},{2}) -- ({0},0);'.format(curr, before, after))
    if changed != flag:
        flag = changed
        print('\draw ({0},0pt) -- ({0},-2pt) node[anchor=north]'.format(curr) + '{' + str(flag) + '};')
   

